package com.letfox.test.example;

import java.math.BigDecimal;
import java.util.Date;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import com.letfox.common.util.UUIDHexGenerator;
import com.letfox.finance.dao.AccountRlInoutDao;
import com.letfox.finance.dao.OutcomeDetailDao;
import com.letfox.finance.enums.FINDelEnums;
import com.letfox.finance.enums.FINInoutPayChannelEnums;
import com.letfox.finance.enums.FINInoutTypeEnums;
import com.letfox.finance.model.FINAccountRlInout;
import com.letfox.finance.model.FINOutcomeDetail;
import com.letfox.test.util.MyBatisUtil;

public class OutcomeDetailExample {

	private OutcomeDetailDao outcomeDetailDao;
	
	@Test
	public void add(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		FINOutcomeDetail finOutcomeDetail = new FINOutcomeDetail();
		finOutcomeDetail.setFinOutcomeId(UUIDHexGenerator.generator());
		finOutcomeDetail.setFinAvailAmount(new BigDecimal("100"));
		finOutcomeDetail.setFinOutAmount(new BigDecimal("50"));
		finOutcomeDetail.setCreateTime(new Date());
		finOutcomeDetail.setCreateBy("admin");
		finOutcomeDetail.setDel(FINDelEnums.UDMDel.EFFECTIVE.getValue());
		outcomeDetailDao = session.getMapper(OutcomeDetailDao.class);
		outcomeDetailDao.insertSelective(finOutcomeDetail);
	}
	
	@Test
	public void update(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		FINOutcomeDetail finOutcomeDetail = new FINOutcomeDetail();
		finOutcomeDetail.setDel(FINDelEnums.UDMDel.DELETE.getValue());
		outcomeDetailDao = session.getMapper(OutcomeDetailDao.class);
		outcomeDetailDao.updateByPrimaryKeySelective(finOutcomeDetail);
	}
	
	@Test
	public void select(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		outcomeDetailDao = session.getMapper(OutcomeDetailDao.class);
		FINOutcomeDetail finOutcomeDetail = outcomeDetailDao.selectByPrimaryKey("40289a81628bbbeb01628bbbeb390000");
		System.out.println(finOutcomeDetail.toString());
	}

}
